package com.pray.praymall.search.thread;

import java.io.File;

/**
 * 重命名文件
 *
 * @author 魂悸魄
 * @date 2020/9/19 10:20
 */
public class BatchRenameFile {
    public static void main(String[] args) {
        File file = new File("F:\\JavaEE全套视频\\谷粒商城\\高可用集群篇");
        File[] files = file.listFiles();
        for (File f : files) {
            if (f.isFile()) {
                String name = f.getName();
                String suffix = name.substring(name.length() - 4);
                String newName = name.substring(0, name.indexOf("【"));
                f.renameTo(new File(f.getParent() + File.separator + newName + suffix));
            }
        }
        System.out.println("改名完成");
    }
}
